package cn.demo.gecco.geccobean;

import com.geccocrawler.gecco.annotation.PipelineName;
import com.geccocrawler.gecco.pipeline.Pipeline;
import com.geccocrawler.gecco.request.HttpRequest;
import com.geccocrawler.gecco.scheduler.SchedulerContext;
import org.springframework.util.StringUtils;

/**
 * @ClassName:
 * @PackageName: cn.demo.gecco.geccobean
 * @author: youjp
 * @create: 2019-11-06 11:00
 * @description:  todo 后续业务处理单元
 * @Version: 1.0
 */
@PipelineName("allSortPipeline")
public class AllSortPipeline  implements Pipeline<AllSort> {


    @Override
    public void process(AllSort allSort) {
        System.out.println("==========单页房屋信息处理管道==========");

        for(int i=0;i<allSort.getHouseInfoList().size();i++){
            HttpRequest currRequest = allSort.getRequest();
            //System.out.println(allSort.getHouseInfoList().get(i));    //获取单个房屋信息
            HouseInfo houseInfo=allSort.getHouseInfoList().get(i);
            //
            if(!StringUtils.isEmpty(houseInfo.getUrl())){
                //加入队列
               // SchedulerContext.into(currRequest.subRequest(houseInfo.getUrl()));
            }
        }

        //请求下一页
        HttpRequest currRequest = allSort.getRequest();
        SchedulerContext.into(currRequest.subRequest(allSort.getNextPage()));

    }
}
